package threaddemo7;

import java.util.concurrent.FutureTask;

/**
 * Created by L.jp
 * Description:
 * User: 86189
 * Date: 2022-08-06
 * Time: 19:23
 */
//线程调度是分为轮流调度也就是靠时间片轮换，还有就是抢占式调度就是并发，是随机的，靠的是进程的优先级
public class Testdemo {
    public static void main(String[] args) {
        MyCallable m1=new MyCallable();
        FutureTask<String> f=new FutureTask<>(m1);
        Thread t1=new Thread(f);
        t1.setName("线程1");
        //优先级只能说明线程抢占到cpu的机率更高
        t1.setPriority(1);
        t1.start();
        //获取线程的优先级，可以看源码看看线程的优先级，默认是5，最小是1，最大是10
        System.out.println("优先级"+t1.getPriority());
        
        MyCallable m2=new MyCallable();
        FutureTask<String> f2=new FutureTask<>(m2);
        Thread t2=new Thread(f2);
        t2.setName("线程2");
        t2.setPriority(2);
        t2.start();
        //获取线程的优先级
        System.out.println("优先级"+t2.getPriority());
    }
}
